<template>
        <div class="big">
            <div>
                 <div class="head">
                        <ul>
                            <!-- <div v-for="item in tabs[index].name" :key="item.til"> -->
                            <li><router-link to="/message">钓况</router-link></li>
                            <li class="hea"><router-link to="/ab">关注</router-link></li>
                            <li><router-link to="/ne">渔汛</router-link></li>
                        </ul>
                        <span class="sp2">
                        <router-link to="/search">
                        <van-icon name="search" />搜钓场</router-link></span>
                 </div>
                <div class="nav">
                    <span @click="index=i" v-bind:class="index == i? 'active':''" 
                    v-for="(item,i) in tabs" :key="item.til">{{item.til}}
                    </span>
                </div>
                <div class="caption">
                    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
                        <van-swipe-item><img src="https://img1.baidu.com/it/u=2113497278,507990725&fm=253&fmt=auto&app=138&f=JPEG?w=470&h=600" alt=""></van-swipe-item>
                        <van-swipe-item><img src="https://img1.baidu.com/it/u=2289311225,218634674&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=353" alt=""></van-swipe-item>
                        <van-swipe-item><img src="https://img1.baidu.com/it/u=2186291306,2518932653&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=349" alt=""></van-swipe-item>
                    </van-swipe> 
                </div>
                <div class="list">
                    <span>头筹</span>
                    <span>我的鱼票</span>
                    <span>鱼获榜单</span>
                    <span>钓场入驻</span>
                </div>  
            </div>
                    <div class="cap">
                        <div class="list1" v-for="(item) in pageObj" :key="item.id">
                         <ul>
                             <li>
                              <img :src="item.avatar_url" alt="">
                              <span class="po1">{{item.user_name}}</span>
                              <span class="po2">{{item.create_at | setTime}}</span>
                              <!-- | setTime -->
                              <span class="po3">{{item.type}}</span>
                             </li>
                             <li>
                                <img :src="item.video" alt="">
                             </li>
                             <li>
                                <span class="po4">{{item.content}}</span>
                             </li>
                             <li>
                                <span class="po5">{{item.look}}查看</span>
                                <span class="po6">
                                    <van-icon :class="{active:item.is_ups}" name="like-o" />点赞</span>
                                <span>
                                    <van-icon name="more-o" />评论</span>


                                    <p class="tall" v-for="item in pageObj.replices" :key="item.id">
                                        <img :src="item.avatar_url" alt="">
                                        <span class="po1">{{item.user_name}}</span>
                                    </p>


                             </li>
                         </ul>
                        </div>
                    </div>
            </div>     
          
</template>

<script>
import {getTopicList} from './api'
export default {
    name: 'AppIndex',

    data() {         
        return {
            pageObj:[],
            index:0,
            tabs:[
            {
        til:'热门',
        name:'热门'
    },
    {
        til:'最新',
        name:'最新'
    },
    {
        til:'附近',
        name:'附近'
    },
    {
        til:'+ 发布钓况',
        name:'+ 发布钓况'
    }
           ]
        };
    },
    watch: {        
      index: {
        handler() {
          this.getTopicList();
        },
        deep: true,
      },
    },
    mounted() {
        this.getTopicList()
    },
    methods: {
        
        getTopicList(){
            getTopicList().then(res=>{
                this.pageObj=res.data
                console.log(res)
            })           
        }
    },
};
</script>

<style scoped>
.my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 150px;
    text-align: center;
    height: 150px;
    background-color: #39a9ed;
  }
.big{
    width: 100%;
    height: 95vh;
    display: flex;
    flex-direction: column;
}
.cap{
    flex: 1;
    overflow: auto;
}
.tall{
    width: 100%;
    height: 60px;
    border-radius: 1px solid gray;
    position: absolute;
    top: 100px;
}
.p6 .van-icon.active{
     color: red;
}
.head{
    width: 100%;
    height: 40px;
    margin-top: 10px;
}
.head ul{
    display: flex;
    justify-content: center;
}
.head ul li.active{
   font-size: 20px;
}
.hea{
    margin-left: 5px;
    margin-right: 5px;
}
.nav{
    width: 100%;
    height: 40px;
    display: flex;
    flex-direction: row;
    justify-content:  space-around;
    align-items: center;
}
.nav span.active{
    background-color: yellowgreen;
    border-radius: 5px;
}
.list{
    width: 100%;
    height: 40px;
    display: flex;
    flex-direction: row;
    justify-content:  space-around;
    align-items: center;
}
.caption{
    width: 100%;
    height: 150px;
    border: 1px solid gray;
}
.caption img{
    width: 100%;
    height: 150px;
}
.sp1{
    margin-left: 15px;
    margin-right: 15px;
}
.sp2{
    position: absolute;
    top: 10px;
    right: 10px;
}
a{
    color: black;
}
.list1{
    width: 100%;
    height: 300px;
    border: 1px solid gray;
    position: relative;
}
.list1 ul li:nth-of-type(1){
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: space-between;
    margin-top: 7px;
}
.list1 ul{
    width: 95%;
    margin: 0 auto;
    position: relative;
}
.list1 ul img{
    border-radius: 20px;
    width: 40px;
    height: 40px;
}
.po1{
    position: absolute;
    top: 9px;
    left: 60px;
    font-size:13px;
}
.po2{
    position: absolute;
    top: 30px;
    left: 60px;
    font-size: 10px;
    color: gray;
}
.po3{
    font-size: 15px;
    background-color: yellowgreen;
    border-radius: 5px;
    padding: 2px;
    height: 20px;
}
.list1 ul li:nth-of-type(2) img{
   width: 50%;
   height: 200px;
   border-radius: 0px;
}
.po4{
    font-size: 13px;
}
.po5{
    font-size: 13px;
    color: gray;
}
.list1 ul li:nth-of-type(4){
    display: flex;
}
.po6{
    font-size: 14px;
    margin-left: 200px;
    margin-right: 5px;
}
</style>